<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const arr = [{

            "id": 15,

            "name": "逐卜乡",

            "village": [

                {

                    "id": 466,

                    "name": "崇德村",

                    "pid": 15,

                    "village": [

                        {

                            "id": 467,

                            "pid": 466,

                            "name": "伏德屯"

                        },

                        {

                            "id": 468,

                            "pid": 466,

                            "name": "伏隆屯1"

                        },

                        {

                            "id": 469,

                            "pid": 466,

                            "name": "上宙屯"

                        },

                        {

                            "id": 470,

                            "pid": 466,

                            "name": "下宙屯"

                        },

                        {

                            "id": 471,

                            "pid": 466,

                            "name": "板领屯"

                        },

                        {

                            "id": 472,

                            "pid": 466,

                            "name": "那岁屯"

                        },

                        {

                            "id": 473,

                            "pid": 466,

                            "name": "下录屯"

                        },

                        {

                            "id": 474,

                            "pid": 466,

                            "name": "坡贯屯1"

                        },

                        {

                            "id": 475,

                            "pid": 466,

                            "name": "陇关屯"

                        }

                    ]

                },

                {

                    "id": 476,

                    "name": "谷阳村",

                    "pid": 15,

                    "village": [

                        {

                            "id": 477,

                            "pid": 476,

                            "name": "旧州屯"

                        },

                        {

                            "id": 478,

                            "pid": 476,

                            "name": "那禁屯"

                        },

                        {

                            "id": 479,

                            "pid": 476,

                            "name": "农定屯"

                        },

                        {

                            "id": 480,

                            "pid": 476,

                            "name": "谷阳屯"

                        },

                        {

                            "id": 481,

                            "pid": 476,

                            "name": "那叫屯1"

                        },

                        {

                            "id": 482,

                            "pid": 476,

                            "name": "那侣屯"

                        },

                        {

                            "id": 483,

                            "pid": 476,

                            "name": "板海屯"

                        },

                        {

                            "id": 484,

                            "pid": 476,

                            "name": "板佞屯"

                        },

                        {

                            "id": 485,

                            "pid": 476,

                            "name": "板坎屯"

                        },

                        {

                            "id": 486,

                            "pid": 476,

                            "name": "陇善屯1"

                        },

                        {

                            "id": 487,

                            "pid": 476,

                            "name": "伏那屯"

                        },

                        {

                            "id": 488,

                            "pid": 476,

                            "name": "伏排屯"

                        },

                        {

                            "id": 489,

                            "pid": 476,

                            "name": "巴要屯"

                        },

                        {

                            "id": 1397,

                            "pid": 476,

                            "name": "谷眼屯"

                        },

                        {

                            "id": 1404,

                            "pid": 476,

                            "name": "农家屯"

                        },

                        {

                            "id": 1428,

                            "pid": 476,

                            "name": "岜要屯"

                        }

                    ]

                },

                {

                    "id": 490,

                    "name": "牌宗村",

                    "pid": 15,

                    "village": [

                        {

                            "id": 491,

                            "pid": 490,

                            "name": "农造屯"

                        },

                        {

                            "id": 492,

                            "pid": 490,

                            "name": "甫眼屯"

                        },

                        {

                            "id": 493,

                            "pid": 490,

                            "name": "内甫屯"

                        },

                        {

                            "id": 494,

                            "pid": 490,

                            "name": "内弄屯"

                        },

                        {

                            "id": 495,

                            "pid": 490,

                            "name": "内相屯"

                        },

                        {

                            "id": 496,

                            "pid": 490,

                            "name": "排草屯"

                        },

                        {

                            "id": 497,

                            "pid": 490,

                            "name": "那隆屯"

                        },

                        {

                            "id": 498,

                            "pid": 490,

                            "name": "秾江屯"

                        }

                    ]

                },

                {

                    "id": 499,

                    "name": "三叉村",

                    "pid": 15,

                    "village": [

                        {

                            "id": 500,

                            "pid": 499,

                            "name": "三叉屯"

                        },

                        {

                            "id": 501,

                            "pid": 499,

                            "name": "弄松屯"

                        },

                        {

                            "id": 502,

                            "pid": 499,

                            "name": "百定屯"

                        },

                        {

                            "id": 503,

                            "pid": 499,

                            "name": "那广屯"

                        },

                        {

                            "id": 504,

                            "pid": 499,

                            "name": "叫么屯"

                        },

                        {

                            "id": 505,

                            "pid": 499,

                            "name": "长塘屯"

                        },

                        {

                            "id": 506,

                            "pid": 499,

                            "name": "社屯屯"

                        },

                        {

                            "id": 507,

                            "pid": 499,

                            "name": "谷梗屯"

                        },

                        {

                            "id": 508,

                            "pid": 499,

                            "name": "陇急屯"

                        },

                        {

                            "id": 509,

                            "pid": 499,

                            "name": "那劳屯"

                        },

                        {

                            "id": 510,

                            "pid": 499,

                            "name": "陇汤屯"

                        },

                        {

                            "id": 1396,

                            "pid": 499,

                            "name": "谷更屯"

                        },

                        {

                            "id": 1409,

                            "pid": 499,

                            "name": "社屯"

                        }

                    ]

                },

                {

                    "id": 511,

                    "name": "广合村",

                    "pid": 15,

                    "village": [

                        {

                            "id": 512,

                            "pid": 511,

                            "name": "上额屯"

                        },

                        {

                            "id": 513,

                            "pid": 511,

                            "name": "下额屯"

                        },

                        {

                            "id": 514,

                            "pid": 511,

                            "name": "伏隆屯"

                        },

                        {

                            "id": 515,

                            "pid": 511,

                            "name": "下茶屯"

                        },

                        {

                            "id": 516,

                            "pid": 511,

                            "name": "上茶屯"

                        },

                        {

                            "id": 517,

                            "pid": 511,

                            "name": "那忌屯"

                        },

                        {

                            "id": 518,

                            "pid": 511,

                            "name": "板克屯"

                        },

                        {

                            "id": 519,

                            "pid": 511,

                            "name": "那汤屯1"

                        },

                        {

                            "id": 520,

                            "pid": 511,

                            "name": "板角屯2"

                        },

                        {

                            "id": 521,

                            "pid": 511,

                            "name": "内录屯"

                        }

                    ]

                },

                {

                    "id": 522,

                    "name": "锦阁村",

                    "pid": 15,

                    "village": [

                        {

                            "id": 523,

                            "pid": 522,

                            "name": "岜降屯"

                        },

                        {

                            "id": 524,

                            "pid": 522,

                            "name": "板棉屯"

                        },

                        {

                            "id": 525,

                            "pid": 522,

                            "name": "板伶屯"

                        },

                        {

                            "id": 526,

                            "pid": 522,

                            "name": "岩洋屯"

                        },

                        {

                            "id": 527,

                            "pid": 522,

                            "name": "板罗屯1"

                        },

                        {

                            "id": 528,

                            "pid": 522,

                            "name": "甫下屯"

                        },

                        {

                            "id": 529,

                            "pid": 522,

                            "name": "岜余屯"

                        },

                        {

                            "id": 530,

                            "pid": 522,

                            "name": "板阁屯"

                        }

                    ]

                },

                {

                    "id": 531,

                    "name": "逐卜村",

                    "pid": 15,

                    "village": [

                        {

                            "id": 532,

                            "pid": 531,

                            "name": "逐卜旧街"

                        },

                        {

                            "id": 533,

                            "pid": 531,

                            "name": "新街屯1"

                        },

                        {

                            "id": 534,

                            "pid": 531,

                            "name": "寺良屯"

                        },

                        {

                            "id": 535,

                            "pid": 531,

                            "name": "岜埠屯"

                        },

                        {

                            "id": 536,

                            "pid": 531,

                            "name": "隘口屯1"

                        },

                        {

                            "id": 537,

                            "pid": 531,

                            "name": "布望屯"

                        },

                        {

                            "id": 538,

                            "pid": 531,

                            "name": "岜马屯"

                        },

                        {

                            "id": 539,

                            "pid": 531,

                            "name": "布平屯"

                        },

                        {

                            "id": 540,

                            "pid": 531,

                            "name": "岜会屯"

                        },

                        {

                            "id": 541,

                            "pid": 531,

                            "name": "冷岜屯"

                        },

                        {

                            "id": 542,

                            "pid": 531,

                            "name": "板旦屯1"

                        },

                        {

                            "id": 543,

                            "pid": 531,

                            "name": "板弄屯"

                        },

                        {

                            "id": 1429,

                            "pid": 531,

                            "name": "咘平屯"

                        },

                        {

                            "id": 1430,

                            "pid": 531,

                            "name": "咘望屯"

                        }

                    ]

                },

                {

                    "id": 544,

                    "name": "板要村",

                    "pid": 15,

                    "village": [

                        {

                            "id": 545,

                            "pid": 544,

                            "name": "板要屯"

                        },

                        {

                            "id": 546,

                            "pid": 544,

                            "name": "岩烹屯"

                        },

                        {

                            "id": 547,

                            "pid": 544,

                            "name": "农橄屯1"

                        },

                        {

                            "id": 548,

                            "pid": 544,

                            "name": "陇沙屯"

                        },

                        {

                            "id": 549,

                            "pid": 544,

                            "name": "板隆屯"

                        },

                        {

                            "id": 550,

                            "pid": 544,

                            "name": "三合屯"

                        },

                        {

                            "id": 551,

                            "pid": 544,

                            "name": "甫除屯"

                        },

                        {

                            "id": 552,

                            "pid": 544,

                            "name": "端得屯"

                        },

                        {

                            "id": 553,

                            "pid": 544,

                            "name": "那社屯"

                        },

                        {

                            "id": 1403,

                            "pid": 544,

                            "name": "农敢屯"

                        }

                    ]

                },

                {

                    "id": 554,

                    "name": "卫国村",

                    "pid": 15,

                    "village": [

                        {

                            "id": 555,

                            "pid": 554,

                            "name": "岜邓屯"

                        },

                        {

                            "id": 556,

                            "pid": 554,

                            "name": "板凌屯"

                        },

                        {

                            "id": 557,

                            "pid": 554,

                            "name": "板滨屯"

                        },

                        {

                            "id": 558,

                            "pid": 554,

                            "name": "岜六屯"

                        },

                        {

                            "id": 559,

                            "pid": 554,

                            "name": "弄矻屯"

                        },

                        {

                            "id": 560,

                            "pid": 554,

                            "name": "安马屯1"

                        },

                        {

                            "id": 561,

                            "pid": 554,

                            "name": "农内屯"

                        },

                        {

                            "id": 562,

                            "pid": 554,

                            "name": "楞犸屯"

                        },

                        {

                            "id": 1406,

                            "pid": 554,

                            "name": "弄矻屯"

                        }

                    ]

                },

                {

                    "id": 563,

                    "name": "立信村",

                    "pid": 15,

                    "village": [

                        {

                            "id": 564,

                            "pid": 563,

                            "name": "弄来屯"

                        },

                        {

                            "id": 565,

                            "pid": 563,

                            "name": "新村屯"

                        },

                        {

                            "id": 566,

                            "pid": 563,

                            "name": "叫里屯"

                        },

                        {

                            "id": 567,

                            "pid": 563,

                            "name": "板莫屯1"

                        },

                        {

                            "id": 568,

                            "pid": 563,

                            "name": "板苗屯"

                        },

                        {

                            "id": 569,

                            "pid": 563,

                            "name": "那弄屯2"

                        },

                        {

                            "id": 570,

                            "pid": 563,

                            "name": "谷布屯"

                        },

                        {

                            "id": 571,

                            "pid": 563,

                            "name": "板密屯"

                        }

                    ]

                },

                {

                    "id": 572,

                    "name": "弄岗村",

                    "pid": 15,

                    "village": [

                        {

                            "id": 573,

                            "pid": 572,

                            "name": "甫茶屯2"

                        },

                        {

                            "id": 574,

                            "pid": 572,

                            "name": "楞垒屯"

                        },

                        {

                            "id": 575,

                            "pid": 572,

                            "name": "坡那屯2"

                        },

                        {

                            "id": 576,

                            "pid": 572,

                            "name": "板新屯2"

                        },

                        {

                            "id": 577,

                            "pid": 572,

                            "name": "板牌屯"

                        },

                        {

                            "id": 578,

                            "pid": 572,

                            "name": "派母屯"

                        },

                        {

                            "id": 579,

                            "pid": 572,

                            "name": "陇广屯"

                        },

                        {

                            "id": 580,

                            "pid": 572,

                            "name": "那坎屯"

                        },

                        {

                            "id": 581,

                            "pid": 572,

                            "name": "下案屯"

                        },

                        {

                            "id": 582,

                            "pid": 572,

                            "name": "板晓屯"

                        },

                        {

                            "id": 583,

                            "pid": 572,

                            "name": "陇亨屯"

                        },

                        {

                            "id": 584,

                            "pid": 572,

                            "name": "上案屯"

                        },

                        {

                            "id": 585,

                            "pid": 572,

                            "name": "伏院屯"

                        },

                        {

                            "id": 586,

                            "pid": 572,

                            "name": "汪那屯"

                        },

                        {

                            "id": 587,

                            "pid": 572,

                            "name": "廷额屯"

                        }

                    ]

                }

            ]

        }]
        
        function getIndexById(arr,id){
            const _arr = [...arr]
            console.log('_arr', _arr)
            let lv1Index = ''
            let lv2Index = ''
            let lv3Index = ''

            _arr.forEach((lv1Item,lv1idx)=>{
                lv1Item.village.forEach((lv2Item,lv2idx)=>{
                    lv2Item.village.forEach((lv3Item,lv3idx)=>{
                        if(lv3Item.id == id){
                            lv1Index = lv1idx
                            lv2Index = lv2idx
                            lv3Index = lv3idx
                        }
                    })
                })
            })

            return [lv1Index,lv2Index,lv3Index]
        }

       const res =  getIndexById(arr,475)
       console.log('res', res)
   </script>
</body>

</html>